/*
 * @Description: 
 * @Author: 马爽
 * @Date: 2021-03-04 10:53:17
 * @LastEditTime: 2021-03-10 13:22:27
 * @LastEditors: 马爽
 */
import { FC, useEffect } from 'react';
import { useDispatch, useSelector, userManageModelState,UserModelState } from 'umi';
import './addUser.less';
import Adduser from '@/pages/user/component/Adduser';
import Addidentity from '@/pages/user/component/Addidentity';
import Addapi from '@/pages/user/component/Addapi';
import Setapi from '@/pages/user/component/Setapi';
import SetIdentityView from '@/pages/user/component/SetIdentityView';
import AddauthorityView from '@/pages/user/component/AddauthorityView';
import React from 'react';



const Page:FC = () => {
  const dispatch = useDispatch();

  

  useEffect(() => {
    dispatch({
      type:'userManage/getIdentityList'
    }),
    dispatch({
      type:'userManage/getViewAuthorityList'
    }),
    dispatch({
      type:'userManage/getAuthorityList'
    }),
    dispatch({
      type:'userManage/getUserList'
    })
  },[])
  let { userList } = useSelector((state:{userManage:userManageModelState}) => state.userManage);
  // console.log(userList);
  const { identityList, viewAuthorityList, authorityList } = useSelector((model:{userManage:userManageModelState,user:UserModelState}) =>{
    return {... model.userManage,...model.user}
  })

  return (
    <div className='main'>
      <h2>添加用户</h2>
      <div className="form">
        {/* 添加用户 */}
        <Adduser identityList={identityList} userList={userList}></Adduser>

        {/* 添加身份 */}
        <Addidentity></Addidentity>

        {/* 添加api接口权限 */}
        <Addapi></Addapi>
        
        {/* 添加视图接口权限 */}
        <AddauthorityView viewAuthorityList={viewAuthorityList}></AddauthorityView>
        
        {/* 给身份设置api接口权限 */}
        <Setapi identityList={identityList} authorityList={authorityList}></Setapi>

        {/* 给身份设置视图权限 */}
        <SetIdentityView identityList={identityList} viewAuthorityList={viewAuthorityList}></SetIdentityView>          
      </div>
    </div>
  );
}

export default Page;
